import requests

url = "http://www.baidu.com"

headers = {
    "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1"
    # "Referer": "https://fanyi.baidu.com/?aldtype=16047"
}
response = requests.get(url,headers=headers)
# response = requests.get(url)
# print(response)

#  获取网页的html字符串
response.encoding = "utf-8"

# print(response.text)

# print(response.request.url)
# print(response.url)
# print(response.request.headers)
# print(response.headers)
print(response.content.decode())